package controller

import (
	"device-admin/internal/app/web/service/log"
	"device-admin/internal/define"
	"strconv"

	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
)

type Log struct{}

// OperationLog 操作日志
func (Log) OperationLog(c *gin.Context) {
	operationType, _ := strconv.Atoi(c.Query("type"))
	startTime, _ := strconv.Atoi(c.Query("start_time"))
	endTime, _ := strconv.Atoi(c.Query("end_time"))
	page, _ := strconv.Atoi(c.Query("page"))
	limit, _ := strconv.Atoi(c.Query("limit"))
	list, total, err := log.OperationLogList(
		c.Request.Context(),
		define.OperationType(operationType),
		c.Query("obj_id"),
		c.Query("association_id"),
		c.GetHeader("Accept-Language"),
		int64(startTime),
		int64(endTime),
		page,
		limit,
	)
	response.JSON(c, map[string]interface{}{
		"list":  list,
		"total": total,
	}, err)
}
